package com.xyd.service.impl;

import com.xyd.mapper.OrderDetailMapper;
import com.xyd.service.OrderDetailService;
import com.xyd.util.MybatisUtil;
import org.apache.ibatis.session.SqlSession;

/**
 * 类描述：
 *
 * @author 张吉哲
 * @date 2021/1/11 16:30
 */
public class OrderDetailServiceImpl implements OrderDetailService {

  private SqlSession sqlSession;

  @Override
  public Boolean changeProductNum(int newNum, double price, int eodId) {
    sqlSession = MybatisUtil.getSqlSession();
    Boolean flag = sqlSession.getMapper(OrderDetailMapper.class)
        .changeProductNum(newNum, price, eodId);
    if (flag) {
      sqlSession.commit();
    }
    MybatisUtil.closeSqlSession(sqlSession);
    return flag;
  }

  @Override
  public Boolean delOrderByEodId(Long eodId) {
    sqlSession = MybatisUtil.getSqlSession();
    Boolean flag = sqlSession.getMapper(OrderDetailMapper.class).delOrderByEodId(eodId);
    if (flag) {
      sqlSession.commit();
    }
    MybatisUtil.closeSqlSession(sqlSession);
    return flag;
  }
}
